package com.plate.app.curriculum.knowledge.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.plate.app.base.controller.AppController;
import com.plate.app.curriculum.knowledge.service.AppKnowService;

/**
 * @作者:Rainsponsor
 * @E-mail:xianzel@163.com
 * @时间: 2015-1-30
 * @描述:
 */
@Controller
@Scope("prototype")
@RequestMapping("/mobile/know")
public class AppKnowController extends AppController {
	
	@Autowired
	private AppKnowService service;
	
	/**
	 * http://localhost:8080/plate/mobile/know/correct/{knowledge_id}/{content}/{user_id}/{version}
	 * http://localhost:8080/plate/mobile/know/correct/1/测试测试/1/1
	 * 记录用户纠错信息
	 * @param id		java.lang.Integer 知识点id
	 * @param content	java.lang.String  纠正内容
	 * @param userid	java.lang.Integer 用户id	如果userid为0则说明未登陆用户
	 * @param version	java.lang.Integer 纠错所操作的App版本号 
	 * @return	JSONObject
	 * 			{result:200} //成功
	 * 			{result:0} //失败
	 */
	@RequestMapping("/correct/{knowledge_id}/{content}/{user_id}/{version}")
	@ResponseBody
	public String correct(
			@PathVariable Integer knowledge_id,
			@PathVariable String content,
			@PathVariable Integer user_id,
			@PathVariable Integer version){
		try{
			service.correct(knowledge_id, content, user_id,version);
			return "{result:"+APP_REQUEST_SUCCESS+"}";//处理成功  200
		}catch(Exception e){
			e.printStackTrace();
			return "{result:"+APP_REQUEST_ERROR+"}";//处理失败   0
		}
	}
	
	public List<Map<String,Object>> getCorrect(@RequestParam("userId") Integer userId){
		
		return null;
	}
	
}
